#include <iostream>
#include <poll.h>
#include <unistd.h>

using namespace std;

int main()
{  
    char buffer[1024];
    struct pollfd pf;
    pf.fd = 0;
    pf.events = POLLIN;
    while(true)
    {
        int ret = poll(&pf, 1, 1000);
        if(ret < 0)
        {
            exit(1);
        }
        else if(ret == 0)
        {
            cout << "time out" << endl;
            continue;
        }
        else
        {
            ssize_t sz = read(pf.fd, buffer, sizeof(buffer) - 1);
            buffer[sz - 1] = 0;
            cout << "echo# " << buffer << endl;
        }
    }
    return 0;
}